<Project DefaultTargets="WasmBuildApp">
  <PropertyGroup>
    <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(TestBinDir)\obj\</IntermediateOutputPath>
  </PropertyGroup>

  <Import Project="$(CORE_ROOT)\build\WasmApp.InTree.props" />
  <PropertyGroup>
    <ImportTargetingPacksTargetsInWasmAppTargets>false</ImportTargetingPacksTargetsInWasmAppTargets>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
    <MicrosoftNetCoreAppRuntimePackDir>$(CORE_ROOT)\runtimepack-non-existent</MicrosoftNetCoreAppRuntimePackDir>
    <MicrosoftNetCoreAppRuntimePackRidDir>$(CORE_ROOT)\runtimepack</MicrosoftNetCoreAppRuntimePackRidDir>
    <MicrosoftNetCoreAppRuntimePackRidLibTfmDir>$(MicrosoftNetCoreAppRuntimePackRidDir)\native</MicrosoftNetCoreAppRuntimePackRidLibTfmDir>
    <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
    <BuildDir>$(MSBuildThisFileDirectory)\obj\$(Configuration)\wasm</BuildDir>
    <AppDir>$(TestBinDir)/WasmApp/</AppDir>
    <NETCoreAppMaximumVersion>99.0</NETCoreAppMaximumVersion>
    <IsBrowserWasmProject>true</IsBrowserWasmProject>
    <WasmGenerateAppBundle>true</WasmGenerateAppBundle>

    <WasmAppBuilderTasksAssemblyPath>$(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll</WasmAppBuilderTasksAssemblyPath>
    <MonoAOTCompilerTasksAssemblyPath>$(CORE_ROOT)\MonoAOTCompiler\MonoAOTCompiler.dll</MonoAOTCompilerTasksAssemblyPath>
    <MonoTargetsTasksAssemblyPath>$(CORE_ROOT)\MonoTargetsTasks\MonoTargetsTasks.dll</MonoTargetsTasksAssemblyPath>
    <WasmBuildAppDependsOn>BuildApp;$(WasmBuildAppDependsOn)</WasmBuildAppDependsOn>
  </PropertyGroup>

  <Target Name="BuildApp">
    <PropertyGroup>
      <WasmMainAssemblyFileName>$(TestAssemblyFileName)</WasmMainAssemblyFileName>
      <WasmAppDir>$(AppDir)</WasmAppDir>
      <WasmMainJSPath>$(CORE_ROOT)\runtime-test\test-main.js</WasmMainJSPath>
      <WasmResolveAssembliesBeforeBuild>true</WasmResolveAssembliesBeforeBuild>
      <WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
      <WasmSkipMissingAssemblies>true</WasmSkipMissingAssemblies>
    </PropertyGroup>

    <ItemGroup>
      <WasmExtraFilesToDeploy Include="$(CORE_ROOT)\runtime-test\index.html" />
      <WasmExtraFilesToDeploy Include="$(CORE_ROOT)\runtime-test\test-main.js" />
      <WasmAssembliesToBundle Include="$(TestBinDir)\*.dll" />
      <WasmAssembliesToBundle Include="$(CORE_ROOT)\System.Runtime.InteropServices.JavaScript.dll" />
      <WasmAssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)\native"/>
      <WasmAssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)"/>
      <WasmAssemblySearchPaths Include="$(CORE_ROOT)/TargetingPack" />
      <WasmAssemblySearchPaths Include="$(TestBinDir)" />
    </ItemGroup>

    <Message Importance="High" Text="AppDir: $(AppDir)" />
    <Message Importance="High" Text="TestBinDir: $(TestBinDir)" />
    <Message Importance="High" Text="ArtifactsBinDir: $(ArtifactsBinDir)" />
  </Target>

  <Import Project="$(CORE_ROOT)\build\WasmApp.InTree.targets" />
</Project>
